Computed Values

Count Distinct Values in a Table Column

Description
This customization shows how to count distinct values in a table column.
Variables
TableControl
Select a table control
Table Name
Select a database table
Field Name
Select a field in the table
Applies to
Page class
Code
 
''' 
''' This method counts distinct values in a table column.
''' 
Public Function GetCount() As Long

    dim oB as OrderBy = new OrderBy(false,true)
    oB.Add(${${Table Name}ClassName}.${Field Name},BaseClasses.Data.OrderByItem.OrderDir.Asc)
    dim tempArray() as string = ${${Table Name}ClassName}.GetValues(${${Table Name}ClassName}.${Field Name}, new WhereClause(), oB, ${${Table Name}ClassName}.MAX_BATCH_SIZE)
    return tempArray.Length
    
End Function
     

Terms of Service Privacy Statement